<!doctype html>
<html  class="x-admin-sm">
<head>
	<meta charset="UTF-8">
	<title>纸条后台</title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/login.css">
	  <link rel="stylesheet" href="./css/index.css">
    <script src="./lib/layui/layui.js" charset="utf-8"></script>

    <style>
        #login_area
        {
           margin-top: 100px;
        }
    </style>
</head>
<body class="login-bg">

    <div id="login_area" class="login layui-anim layui-anim-up">
        <div class="message">纸条后台登录界面</div>
        <div id="darkbannerwrap"></div>
            <input name="username" id="m_name" placeholder="用户名"  type="text" lay-verify="required" class="layui-input" >
            <hr class="hr15">
            <input name="password" id="m_pwd" lay-verify="required" placeholder="密码"  type="password" class="layui-input">
            <hr class="hr15">
            <button type="button" style="width:100%;" id="login_submit" class="layui-btn layui-btn-lg">登录</button>
            <hr class="hr20" >
    </div>

    <script>
            layui.use('layer', function() {
                var $ = layui.jquery;
                var layer=layui.layer;
                //ajax提交处理登录请求
                $("#login_submit").click(function ()
                {
                    let m_name=$("#m_name").val()
                    let m_pwd=$("#m_pwd").val()
                    if(m_name==""||m_pwd=="")
                    {
                        layer.msg('请将信息填写完整', {icon: 5});
                        return;
                    }
                    $.ajax({
                        url: "login/account_login",
                        type: 'post',
                        data: {"name":m_name,"pwd":m_pwd},
                        success: function (res)
                        {
                           if(res.status==="handle_success")
                           {
                                //保存token到本地
                                 window.localStorage.managerToken=res.data;
                                 //跳转到首页
                                 window.location.assign("index");
                           }
                           else if(res.status==="manager_login_error")
                           {
                               layer.msg('用户名或者密码错误', {icon: 5});
                           }
                           else
                           {
                               layer.msg('出现异常', {icon: 5});
                           }
                        },
                        error: function (res)
                        {
                            layer.msg('出现异常', {icon: 5});
                        }
                    })
                })
            })
    </script>
</body>
</html>